import instance from '@/utils/https'

/**
 * 获取结算信息
 */
export const getCheckoutInfoAPI = () => {
  return instance({
    url: '/member/order/pre'
  })
}

// 创建订单
export const createOrderAPI = data => {
  return instance({
    url: '/member/order',
    method: 'POST',
    data
  })
}
export const getOrderAPI = id => {
  return instance({
    url: `/member/order/${id}`
  })
}

export const deleteOrderAPI = (id, cancelReason) => {
  return instance({
    url: `/member/order/${id}/cancel`,
    method: 'PUT',
    data: { cancelReason }
  })
}

export const addAddressAPI = data => {
  return instance({
    url: '/member/address',
    method: 'POST',
    data: data
  })
}

export const getAddressAPI = () => {
  return instance({
    url: '/member/address',
    method: 'GET'
  })
}
export const deleteAddressAPI = id => {
  return instance({
    url: `/member/address/${id}`,
    method: 'DELETE'
  })
}
